/**
 * YESBRAIN Javascript Library;
 * @author gongji
 */

	/*
	 * Drop Table SQL Language
	 * Can use basic drop table language
	 */

YESBRAIN.JSQL.DROPTABLE = {

	parseTable : function(sql){
		var re = new RegExp(/\(.+\)/ig);
		var ree;
		var res;
		if(re.exec(sql)) {
			ree = new RegExp(/drop\s+table\s+(.+)\s*\(/ig);
		} else {
			ree = new RegExp(/drop\s+table\s+(.+)$/ig);
		};
		res = ree.exec(sql);
		if(res) {
			return res[1]
		}
		else {
			return null;
		}
	},
	
	
	executeDropTable : function(sql) {
		var table = this.parseTable(sql);
		if("undefined" == typeof window[table]) {
			alert("table not existed");
			return false;
		} else {
			delete window[table];
			return true;
		};
	}
};